package thinkingJava.chapter15;

import java.util.ArrayList;
import java.util.Collection;
/**
 * util
 * @author Administrator
 *
 */
public class Generators {
	public static <T> Collection<T> fill(Collection<T> col, Generator<T> gen, int n) {
		for (int i = 0; i < n ; i ++) {
			col.add(gen.next());
		}
		return col;
	}
	public static void main(String[] args) {
		Collection<Coffee> cc = fill(new ArrayList<Coffee>(), new CoffeeGenerator(),4);
		for (Coffee c : cc) {
			System.out.println(c);
		}
		Collection<Integer> ci = fill(new ArrayList<Integer>() , new Fibonacci(), 12);
		for (Integer i : ci) {
			System.out.print(i + " ");
		}
	}

}
